package demon1;

import com.sun.source.tree.Tree;
class TreeTest{
    static class TreeNode2{
        public char val;
        public TreeTest.TreeNode2 left;
        public TreeTest.TreeNode2 right;
        public TreeNode2(char val){
            this.val=val;
        }
    }

    public TreeTest.TreeNode2 creatTree2(){
        TreeTest.TreeNode2 A = new TreeTest.TreeNode2('A');
        TreeTest.TreeNode2 B = new TreeTest.TreeNode2('B');
        TreeTest.TreeNode2 C = new TreeTest.TreeNode2('C');
        TreeTest.TreeNode2 D = new TreeTest.TreeNode2('D');
        TreeTest.TreeNode2 E = new TreeTest.TreeNode2('E');
        TreeTest.TreeNode2 F = new TreeTest.TreeNode2('F');
        TreeTest.TreeNode2 G = new TreeTest.TreeNode2('G');
        TreeTest.TreeNode2 H = new TreeTest.TreeNode2('H');
        A.left=B;
        A.left = B;
        A.right = C;
        B.left = D;
        B.right = E;
        C.left = F;
        C.right = G;
        E.right = H;
        return A;
    }
}
public class Test {
    public static void main(String[] args) {
        Mytree mytree=new Mytree();
        Mytree.TreeNode root=mytree.creatTree() ;
        //System.out.println(mytree.getHeight(root));
        Mytree.TreeNode ret= mytree.find(root,'E');
        System.out.println(ret.val);
        mytree.getKLevelNodeCount(root,3);
        TreeTest treeTest=new TreeTest();
        TreeTest.TreeNode2 root2=treeTest.creatTree2();
//        System.out.println(mytree.isSubtree(root, root));
//        mytree.invertTree(root);
        mytree.isBalanced(root);
        mytree.size1(root);
        mytree.getHeight(root);
        mytree.isSameTree(root,root);
        System.out.println(mytree.lowestCommonAncestor(root, 'H', 'D').val);
    }
}
